package com.yznu.jx1;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

@Data
public class Main {
   public static void main(String[] args) {
	   Student student= new Student("admin","1234");
	   List<Student> list = new ArrayList();
	   
	   list.add(student);
	   list.add(new Student("user1","abcd"));
	   
	   String str =JSON.toJSONString(student);
	   //System.out.println(str);
	   //System.out.println(JSON.toJSON(list));
	   
	   JSONObject obj= JSON.parseObject(str);
	   
	   System.out.println(obj);
	   
	   System.out.println(obj.getString("username"));
	   System.out.println(obj.getString("password"));
	   
	   Student s = JSON.toJavaObject(obj, Student.class);
	   System.out.println(s.getPassword()+""+s.getUsername());
	   
   }
}

